<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Models\Smarty;
use App\Transformers\SmartyTransformer;

class SmartiesController extends Controller
{
    public function index()
    {
    	return $this->response->collection(Smarty::all(), new SmartyTransformer());
    }

    public function show(Smarty $smarty)
    {
    	return $this->response->item($smarty, new SmartyTransformer());
    }

    public function store(Request $request, Smarty $smarty)
    {
    	$smarty->fill($request->all());
    	$smarty->save();

    	return $this->response->item($smarty, new SmartyTransformer());
    }
    
    public function update(Request $request, Smarty $smarty)
    {
    	$smarty->fill($request->all());
    	$smarty->update();

    	return $this->response->item($smarty, new SmartyTransformer());
    }


    public function destroy(Smarty $smarty)
    {
    	$smarty->delete();

    	return $this->response->noContent();
    }
}
